﻿using System;
using EntityObject;
using SharedLibraries;
using SharedLibraries.Constants;
using ThangNM_LIB.DB;
using ThangNM_LIB.FUNC;

namespace ThangNM.Admin
{
    public partial class FileUI : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.File, ConstEx.funcButtonToolBar.LIST);
            MsgUC1.setClearMsg();
            if (!IsPostBack)
            {
                if ((new ShareDAO.UserDAO()).SelectBy_sPermission(Session["secret"], Convert.ToString(Request.Url.AbsolutePath), ConstEx.funcButtonToolBar.MAIN) == false)
                {
                    mtvMain.Visible = false;
                    Commons.setAccessDenied(Page, MsgUC1);
                    return;
                }
            }
        }

        //public override void VerifyRenderingInServerForm(Control control)
        //{
        //    /* Verifies that the control is rendered */
        //}

        #region "Raise Event"
        protected void ViewDetail_Click(object sender, CustomerEventArgs e)
        {
            mtvMain.SetActiveView(vDetail);
            File_DetailUC1.BindDataDetail((FileEO)e.objEntity, ConstEx.FunctionType.View);
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.File, ConstEx.funcButtonToolBar.DETAIL);
        }

        protected void Notification_Click(object sender, CustomerEventArgs e)
        {
            MsgUC1.setNotifications(ConstEx.FunctionSetMsg.INFO, e.sMessage);
        }

        protected void Insert_Click(object sender, EventArgs e)
        {
            mtvMain.SetActiveView(vDetail);
            FileEO _FileEO = new FileEO();
            File_DetailUC1.BindDataDetail(_FileEO, ConstEx.FunctionType.Insert);
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.File, ConstEx.funcButtonToolBar.INSERT);
        }

        protected void ViewMessageList_Click(object sender, CustomerEventArgs e)
        {
            MsgUC1.setNotifications(e.iType, e.sMessage);
        }

        protected void ViewMessageDetail_Click(object sender, CustomerEventArgs e)
        {
            if (e.iType == ConstEx.FunctionSetMsg.SUCCESS)
            {
                mtvMain.SetActiveView(vList);
                File_ListUC1.ResetFormSearch();
                File_ListUC1.BindData_List(null);
            }
            MsgUC1.setNotifications(e.iType, e.sMessage);
        }

        protected void BackList_Click(object sender, EventArgs e)
        {
            mtvMain.SetActiveView(vList);
            File_ListUC1.ResetFormSearch();
            File_ListUC1.BindData_List(null);
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.File, ConstEx.funcButtonToolBar.LIST);
        }
        #endregion
    }
}